 //hdu 3714
 
 #include<iostream>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<sstream>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<limits>
using namespace std;
typedef long long ll;
const int inf=1000000000;
const double pi=acos(-1.0);
#define eps (1e-15)
#define clr clear
#define PB push_back
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define X first
#define Y second
#define PII pair<int,int>
#define VI vector<int>
#define VD vector<double>
#define VS vector<string>dd
#define FORD(i,b,c) for(int (i)=(b);(i)>=c;(i)--)
#define REPD(i,c) FORD(i,c,0)
#define FOR(i,b,c) for(int i=(b);i<(c);i++)
#define REP(i,c) FOR(i,0,c)
#define PQ priority_queue
#define L(x) ((x)<<1)
#define R(x) ((x)<<1|1)
#ifdef DBG
#define see(x) (cerr<<"[Line : "<< __LINE__<<"] : "<<#x<<"="<<x<<endl)
#define se(x) cerr<<x<<" "
#else
#define see(x) //
#define se(x) //
#endif

#define maxn  10300
int n,m;

struct node
{
    int a,b,c;
        node(int aa=0,int bb=0,int cc=0){
        a=aa; b=bb; c=cc;
    }
}a[maxn];


double calc(double x)
{
    int i;
    double y=x*x;
    double ans=-inf;
    for(i=0; i<n; i++)
    {
        ans=max(ans,a[i].a*y+a[i].b*x+a[i].c);
    }
    return ans;
}
//三分法求极值
void solve()
{
    double l=0,r=1000;
    double mid,midr;
    double midv,midrv;
    while(l<r-eps)
    {
        mid=(l+r)/2;
        midr=(mid+r)/2;
        midv=calc(mid);
        midrv=calc(midr);
        if(midv<= midrv)    r=midr;
        else l=mid;
    }
    printf("%.4lf\n",calc(l));
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("in","r",stdin);
#endif
    int i,j,k,t;
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        int x,y,z;
        for(i=0; i<n; i++)
        {
            scanf("%d%d%d", &x,&y,&z);
            a[i]=node(x,y,z);
        }
        solve();
    }
}

